package com.yjt.fresh.adpater;

import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yjt.fresh.R;
import com.yjt.fresh.bean.BeanFrgInformationList;
import com.yjt.fresh.constant.MyConstants;

import java.util.List;

public class AdpRvFrgInformationList extends BaseMultiItemQuickAdapter<BeanFrgInformationList,BaseViewHolder> {


    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    public AdpRvFrgInformationList(List<BeanFrgInformationList> data) {
        super(data);
        addItemType(MyConstants.LEFT_RIGHT, R.layout.app_recycle_item_frg_information_list_left_right);
        addItemType(MyConstants.RIGHT_LEFT, R.layout.app_recycle_item_frg_information_list_right_left);
        addItemType(MyConstants.TOP_BOTTOM, R.layout.app_recycle_item_frg_information_list_top_bottom);
    }

    @Override
    protected void convert(BaseViewHolder helper, BeanFrgInformationList item) {
        if ("左图片右标题".equals(item.getSHOWTYPE())) {
            TextView tvTitle = helper.getView(R.id.tvAppRecycleItemFrgInformationListLeftRightTitle);
            TextView tvTime = helper.getView(R.id.tvAppRecycleItemFrgInformationListLeftRightTime);
            ImageView iv = helper.getView(R.id.ivAppRecycleItemFrgInformationListLeftRight);
            tvTitle.setText(item.getTITLE());
            tvTime.setText(item.getCREATETIME());
            Glide.with(iv.getContext()).load(item.getCOVERIMAGE()).into(iv);
        } else if ("左标题右图片".equals(item.getSHOWTYPE())) {
            TextView tvTitle = helper.getView(R.id.tvAppRecycleItemFrgInformationListRightLeftTitle);
            TextView tvTime = helper.getView(R.id.tvAppRecycleItemFrgInformationListRightLeftTime);
            ImageView iv = helper.getView(R.id.ivAppRecycleItemFrgInformationListRightLeft);
            tvTitle.setText(item.getTITLE());
            tvTime.setText(item.getCREATETIME());
            Glide.with(iv.getContext()).load(item.getCOVERIMAGE()).into(iv);
        } else if ("上标题下图片".equals(item.getSHOWTYPE())) {
            TextView tvTitle = helper.getView(R.id.tvAppRecycleItemFrgInformationListTopBottomTitle);
            TextView tvTime = helper.getView(R.id.tvAppRecycleItemFrgInformationListTopBottomTime);
            ImageView iv = helper.getView(R.id.ivAppRecycleItemFrgInformationTopBottom);
            tvTitle.setText(item.getTITLE());
            tvTime.setText(item.getCREATETIME());
            Glide.with(iv.getContext()).load(item.getCOVERIMAGE()).into(iv);
        }
    }
}
